<template>
  <div class="app-container">
    <!-- 视频发送记录搜索栏 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      v-show="showSearch"
      :inline="true"
    >
      <el-form-item label="抖音用户名" prop="tiktokNickName">
        <el-input
          v-model="queryParams.tiktokNickName"
          placeholder="抖音用户名"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发布状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="发布状态"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
<!-- 视频发送列表栏-->
    <el-table
      v-loading="loading"
      :data="videoList"
    >
      <!-- <el-table-column label="活动id" prop="id"/> -->
      <el-table-column label="抖音用户名" prop="tiktokNickName"/>
      <el-table-column label="商家名称" prop="shopName"/>
      <el-table-column label="活动名称" prop="activityName"/>
      <el-table-column label="发布时间" prop="createTime" >
        <template slot-scope="scope">
          <span>{{scope.row.createTime?scope.row.createTime:'---'}}</span>
        </template>
      </el-table-column>
      <el-table-column label="发布状态">
        <template slot-scope="scope">
          <span style="color: #E6A23C" v-if="scope.row.status == 0">未发布</span>
          <span style="color: #67C23A" v-if="scope.row.status == 1">发布成功</span>
          <span style="color: #F56C6C" v-if="scope.row.status == 2">发布失败</span>
        </template>
      </el-table-column>
      <el-table-column label="抓取次数" prop="iteration">
        <template slot-scope="scope">
          <span>{{scope.row.iteration}} / 5</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope" >
          <el-popover trigger="hover" placement="top">
            <p><i class="el-icon-video-play"> 播放: {{scope.row.playCount}}</i></p>
            <p><i class="el-icon-thumb"> 点赞: {{scope.row.diggCount}}</i></p>
            <p><i class="el-icon-share"> 分享: {{scope.row.shareCount}}</i></p>
            <p><i class="el-icon-chat-dot-square"> 评论: {{scope.row.commentCount}}</i></p>
            <p><i class="el-icon-download"> 下载: {{scope.row.downloadCount}}</i></p>
            <p><i class="el-icon-position"> 转发: {{scope.row.forwardCount}}</i></p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">视频数据</el-tag>
            </div>
          </el-popover>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-attract"
            @click="refreshVideoDataHandle(scope.row.id)"
            v-hasPermi="['video:send:refresh']"
          >抓取一次</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {videolist, getvideolist, refreshVideoData} from "@/api/videorecord/videorecord";
import TreeNodeDialogVue from '../tool/build/TreeNodeDialog.vue';

export default {
  data() {
    return {
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      //视频列表数据
      videoList: [],
      // 状态数据字典
      statusOptions: [
        {dictValue: 0, dictLabel: '未发布'}, {dictValue: 1, dictLabel: '发布成功'}, {dictValue: 2, dictLabel: '发布失败'}
      ],
      // 显示搜索条件
      showSearch: true,
      //数据详情表
      table: [],
      //是否显示弹出层
      open: false,
    };
  },
    created() {
        this.getList();
  },
    methods: {
     /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
    /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
    /** 查询视频发送列表 */
        getList() {
            this.loading = true;
            videolist(this.queryParams).then((response) => {
                this.videoList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
     /** 查询更多数据按钮操作 */
        handleUpdate(row) {
            this.table=[];
            const getid = row.id || this.ids;
            getvideolist(getid).then((response) => {
                this.table.push(response.data)
                this.open = true;
            });
        },
      /** 抓取一次最新的抖音视频数据 */
        refreshVideoDataHandle(id) {
            refreshVideoData(id).then((response) => {
                this.getList();
            })
        }
    }
};
</script>

<style>
</style>
